package com.ry.service.controller;

import com.ry.service.model.User;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class ServiceAController {

	@RequestMapping(value = {"/sayHello/{id}"},method = {RequestMethod.GET})
	public String sayHello(@PathVariable("id") Long id, @RequestParam("name") String name, @RequestParam("age") Integer age) {
		System.out.println("打招呼，id=" + id + ", name=" + name + ", age=" + age);
		return "{'msg': 'hello, " + name + "'}";
	}

	@RequestMapping(value = {"/createUser"},method = {RequestMethod.POST})
	public String createUser(@RequestBody User user) {
		System.out.println("创建用户，" + user);
		return "{'msg': 'success'}";
	}

	@RequestMapping(value = {"/getById/{id}"},method = {RequestMethod.GET})
	public User getById(@PathVariable("id") Long id) {
		System.out.println("查询用户，id=" + id);
		return new User(1L, "张三", 20);
	}

}
